﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ITAP.ShprossesBuilder.Modelling.Components.Actions;

namespace ITAP.ShprossesBuilder.Editor
{
    public partial class DiamondAlignmentForm : Form
    {
        public bool DeleteConnector
        {
            get
            {
                return checkBoxDeleteConnector.Checked;
            }
        }

        public bool FitProfiles
        {
            get
            {
                return checkBoxFitShprosses.Checked;
            }
        }

        private double distance;

        public double Distance
        {
            get { return distance; }
        }

        private DiamondMeasure diamondAlignmentMeasure;

        public DiamondMeasure DiamondAlignmentMeasure
        {
            get { return diamondAlignmentMeasure; }
        }

        public DiamondAlignmentForm(bool fitProfilesVisible, bool deleteConnectorVisible)
        {
            InitializeComponent();
            checkBoxFitShprosses.Visible = fitProfilesVisible;;
            checkBoxDeleteConnector.Visible = deleteConnectorVisible;
            this.UpdateControls();

        }

        private void UpdateControls()
        {
            if (radioButtonDiamondWidth.Checked)
            {
                numericUpDownDiamondWidth.Enabled = true;
                numericUpDownDiamondHeight.Enabled = false;
                numericUpDownDiamondBorder.Enabled = false;
                diamondAlignmentMeasure = DiamondMeasure.Width;
            }
            if (radioButtonDiamondHeight.Checked)
            {
                numericUpDownDiamondWidth.Enabled = false;
                numericUpDownDiamondHeight.Enabled = true;
                numericUpDownDiamondBorder.Enabled = false;
                diamondAlignmentMeasure = DiamondMeasure.Height;
            }
            if (radioButtonDiamondBorder.Checked)
            {
                numericUpDownDiamondWidth.Enabled = false;
                numericUpDownDiamondHeight.Enabled = false;
                numericUpDownDiamondBorder.Enabled = true;
                diamondAlignmentMeasure = DiamondMeasure.DiamondBorder;
            }
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            if(radioButtonDiamondWidth.Checked)
            {
                distance = (double)numericUpDownDiamondWidth.Value;
                diamondAlignmentMeasure = DiamondMeasure.Width;
            }
            if (radioButtonDiamondHeight.Checked)
            {
                distance = (double)numericUpDownDiamondHeight.Value;
                diamondAlignmentMeasure = DiamondMeasure.Height;
            }
            if (radioButtonDiamondBorder.Checked)
            {
                distance = (double)numericUpDownDiamondBorder.Value;
                diamondAlignmentMeasure = DiamondMeasure.DiamondBorder;
            }
        }

        private void radioButtonDiamondWidth_CheckedChanged(object sender, EventArgs e)
        {
            this.UpdateControls();
        }

        private void radioButtonDiamondHeight_CheckedChanged(object sender, EventArgs e)
        {
            this.UpdateControls();
        }

        private void radioButtonDiamondBorder_CheckedChanged(object sender, EventArgs e)
        {
            this.UpdateControls();
        }

    }
}
